//
//  SrEcgAlgorithmResults.h
//  sr01sdkProject
//
//  Created by  on 2024/3/5.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, CA_ECG_Arrhythmia) {
    
    CA_Arrhythmia_NO_FINNISH = 0,      //心律失常检查未完成，没有结果。
    CA_Arrhythmia_NORMAL = 1,          //心律失常检查完成，未发现异常事件。
    CA_Arrhythmia_NOT_ENOUGH_DATA = 2, // 心律失常检查完成，没有收集到足够好的心电图来做出任何决定。请参阅unreadable_reasons。
    CA_Arrhythmia_Bradycardia = 3,     //心律失常检查完成，检测到心动过缓。
    CA_Arrhythmia_AFib = 4,            //心律失常检查完成，检测到心房颤动（AFib）。
    CA_Arrhythmia_Tachycardia = 5,            // 心动过速
    CA_Arrhythmia_Abnormal_unknowReason = 6,            // 心律失常检查完成，有异常，但无法确认心动过缓、心房颤动、心动过速。 不确定
};


typedef NS_ENUM(NSUInteger, CA_ECG_Signal_Quality) {
    CA_ECG_SQ_NO_SIGNAL = 0, // The ECG signal is not present. That is, the user is not connected to the ECG device.
    
    /*The user is connected to an ECG device, but the ECG signal quality is poor and the heartbeat cannot be determined. This may be due to excessive noise on the ECG signal. No ECG algorithm can operate at this level of signal quality.*/
    CA_ECG_SQ_TOO_MUSH_NOISE_NO_HR = 1,
    
    /* 该状态表示在心电图信号中可以确定心跳，但是信号中检测到了大量的噪音。在这种
     信号质量水平下无法进行用户验证/识别。 */
    CA_ECG_SQ_NOISE = 2,
    
    CA_ECG_SQ_GOOD = 3, // 信号很好
};

typedef NS_ENUM(NSInteger, CAecgResProgressType) {
    CA_PRG_HEART_RATE =    1 << 0,       // Heart rate(心率)
    CA_PRG_HRV =           1 << 1,       // HRV
    CA_PRG_Arrhythmias =   1 << 2,       // Arrhythmia test(心率失常检查)
    CA_PRG_STRESS =        1 << 3,       // Stress Index( 压力指数)
    CA_PRG_Energy_Consumption = 1 << 4,  //energy consumption( 能量消耗)
};


@interface CAEcgAlgorithmResults : NSObject

@property(assign, nonatomic)int heartRate; //  心率 0-无效，1-低于 40，254-高于200
@property(assign, nonatomic, readonly)CA_ECG_Arrhythmia arrhythmia; // 心率检查结果

@property(assign, nonatomic, readonly)CA_ECG_Signal_Quality ecgSq; // 信号质量

// 心电图信号振幅很低，请确保接触面清洁，然后重试。
@property(assign, nonatomic, readonly)BOOL low_amplitude;

//心电图信号有明显的噪音，请确保设备没有握得太紧，然后重试。
@property(assign, nonatomic, readonly)BOOL significant_noise;

//心电图信号似乎不稳定，请确保您保持静止，然后重试。
@property(assign, nonatomic, readonly)BOOL unstable_signal;

//没有足够的数据，请确保遵循心电图记录指南，然后重试。
@property(assign, nonatomic, readonly)BOOL not_enough_data;

@property(assign, nonatomic, readonly)uint16_t rmssd, sdnn;

@property(assign, nonatomic, readonly)uint8_t stress; // 压力指数 0-100有效 0XFF表示无效

@property(assign, nonatomic, readonly)uint16_t bmr; // basal metabolic rate, Unit: Cards per minute(基础代谢率, 单位：卡每分钟)

@property(assign, nonatomic, readonly)uint16_t activeCal; // Active energy consumption, Unit: Cards per minute(有功能量消耗, 单位：卡每分钟)

@property(assign, nonatomic, readonly)BOOL present;// 如果用户连接到心电图设备上则为真，否则为假。True if the user is connected to an EKG device, false otherwise.

@property(assign, nonatomic, readonly)BOOL alive;// 如果检测到用户心跳则为真，否则为假。True if the user's heartbeat is detected, false otherwise.

@property(assign, nonatomic, readonly) int avgHeartrate;

@property(assign, nonatomic, readonly) CAecgResProgressType progressType;
@property(assign, nonatomic, readonly) int progress;

-(instancetype)initWithData:(NSData *)data;

@end

NS_ASSUME_NONNULL_END
